<%@page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>项目详细</title>
<%@ include file="/common/header/meta.jsp"%>
<%@ include file="/common/header/script.jsp"%>
<script type="text/javascript">
	var form_url = $.webapp.root + "/admin/site/doc/add.do" ;
	var $col, $contentAttr;
	$(function() {
		
		$("#import_user_data").euploadify({
			required: false, border: false, fileTypeExts : '*.jpg; *.png',
		 	swf: $.webapp.root+'/script/plugins/uploadify/uploadify.swf',
		 	uploader: $.webapp.root+'/fileAction/doNotNeedAuth_Upload.do',
	        onUploadSuccess: function(file, data, response) {
	        	filedata = $.parseJSON(data) ;
	        	$("input[name=pageLogo]").val(filedata.web_url) ;
	        	
	        	
	    		$("#magicView").html("<img src='"+filedata.web_url+"'>") ;
	        }
		});
		
		$col = $("#col").combotree({
			url : $.webapp.root + "/admin/site/column/combo_tree.do",
			idFiled:'pid', textFiled:'name', editable: false, required:false, lines:true, autoShowPanel: false
		}) ;
		$col.combotree("setValue", "${pid}");
		
		$contentAttr = $("#contentAttr").combobox({
			valueField: 'label', textField: 'value',
			panelHeight:'auto', editable:false, autoShowPanel: true,
			data: [{ label: '视频', value: '视频' },{ label: '附件', value: '附件' },
			       { label: '热点', value: '热点' },{ label: '推荐', value: '推荐' },{ label: '图片', value: '图片' }
			      ]
		});
		
		
		u1 = new UE.ui.Editor();
		u1.render('u1');
		u1.addListener('ready', function(e) {
			//编辑，加载表单数据
			if($('input[name=id]').val().length > 0) {
				form_url = $.webapp.root+"/admin/site/doc/update.do" ;
				$.post($.webapp.root+"/admin/site/doc/get.do", {id:$('input[name=id]').val()}, function(result) {
					if (result.id != undefined) {
						$('#basic_page_form').form('load', result);
						
						u1.setContent((undefined==result.centent?"":result.centent));
					}
				}, 'json').error(function() { $.easyui.loaded(); });
			} 
		});
		
		
	});
	
	
	//提交表单数据
	var save = function() {
		if($('#basic_page_form').form('validate')) {
			$.easyui.loading({ msg: "数据提交中，请稍等..." });
			
			var basicform = $.webapp.serializeObject("#basic_page_form") ;
			if(undefined == basicform.pageTitle || "" == basicform.pageTitle.trim()) {
				$.easyui.loaded(); $.messager.alert("警告", "标题不能为空！", "warning");
				return ;
			}
			
			
			$.post(form_url, basicform, function(result) {
				if (result.status) {
					$.easyui.loaded(); alertify.success(result.msg);
					back();
				} else {
					$.easyui.loaded();$.messager.alert("错误", result.msg, "error");
				}
			}, 'json').error(function() { $.easyui.loaded();$.messager.alert("错误", result.msg, "error"); });
		}
	};
	
</script>
</head>

<body>
<div class="easyui-layout" data-options="fit:true">
		
	<div data-options="region:'north',split:false" style="height:60px;border-top:none;border-left:none;border-right:none;border-bottom: 5px solid #3f9bca;">
		<div id="project_detail_head">
			<p id="title" class="nav">
				<strong>文章编辑</strong>
			</p>
			<p id="opts">
				<a class="opt iconrSave" href="javascript:void(0);" onclick="save()">保存</a>
			</p>
		</div>
	</div>
	
	<div data-options="region:'center',border:false">
		<div style="margin: 0px auto">
			<form id="basic_page_form" style="width: 800px;margin: 0px auto">
				<input type="hidden" name="id" value="${id}"/>
				<input type="hidden" name="isPush" value="0"/>
				<div class="form_container">
					<table class="tableform">
						<tr>
							<th style="width: 100px;">文章标题：</th>
							<td>
								<input name="pageTitle" class="easyui-validatebox" style="width:388px;" />
								<input name=pushDate class="Wdate" style="height:23px;width:142px;" type="text" onFocus="WdatePicker({
										isShowClear:true,
										readOnly:true,
										dateFmt: 'yyyy-MM-dd'
										})"/>
							</td>
						</tr>
						<tr>
							<th>所属栏目：</th>
							<td><input id="col" name="pid" style="width:316px;height:25px;" /><a onClick="$col.combotree('setValue','');" class="easyui-linkbutton" data-options="plain: true, iconCls: 'ext_clear'"></a></td>
						</tr>
						<tr>
							<th>上传图片：</th>
							<td>
								<input name="pageLogo" type="hidden" />
								<div id="import_user_data" data-options="required: false" style="border:1px solid red;"></div>
							</td>
						</tr>
						<!-- 
						<tr>
							<th>文章属性：</th>
							<td><input id="contentAttr" name="contentAttr" style="width:316px;height:25px;" /><a onClick="$contentAttr.combobox('setValue','');" class="easyui-linkbutton" data-options="plain: true, iconCls: 'ext_clear'"></a></td>
						</tr>
						 -->
						<tr>
							<td colspan="4"><textarea name="remark" class="easyui-validatebox" data-options="prompt: '文章摘要...'" rows="5" cols="5" style="width:98.5%; height:80px;border:1px solid #ccc; overflow: auto;"></textarea></td>
						</tr>
						<tr>
							<td colspan="4"><textarea id="u1" name="centent" style="width:99.8%;height:600px;"></textarea></td>
						</tr>
					</table>
				</div>
			</form>
		</div>
	</div>
	
</div>

</body>
</html>